<template>
  <div>
    <h2>Counter:{{counter}}</h2>
    <button v-on:click="changeCounter">修改counter</button>
    <hr/>
    <h2>{{why}}</h2>
    <button @click="changeWhy">修改why的值</button>
  </div>
</template>

<script>
export default {
  name: "Counter2",
  props:{
    counter:{
      type:Number,
      default:0
    },
    why:{
      type:String,
      default:''
    }
  },
  emits:['update:counter','update:why'],
  methods:{
    changeCounter(){
      this.$emit('update:counter',123)
    },
    changeWhy(){
      this.$emit('update:why','kobe')
    }
  }
}
</script>

<style scoped>

</style>